package plus.chendd.lock;

import java.util.concurrent.TimeUnit;

public class EndThread002 {
  private static volatile boolean flag = true;
  
  public static void main(String[] args) throws InterruptedException {
    Thread t1 = new Thread(() -> {
      while (flag) {
        // todo
      }
      System.out.println("任务结束");
    });
    
    t1.start();
    
    TimeUnit.SECONDS.sleep(2);
    
    flag = false;
  }
}
